/***************************************
 *所有弹框的基础html样式 
 **************************************/
var dataListHtml=
				"<div id=\"light\" class=\"white_content\" >"+
					"<div id='light-linb' style=\"text-align:right;\">"+
						"<div id=\"configS\" style=\"float:left;\"></div>"+
						"<a href=\"javascript:void(0)\" "+
							"id=\"query\">"+ 
							"[查询]</a>&nbsp;&nbsp;"+
						"<a href=\"javascript:void(0)\" "+
							"id=\"resetConfig\">"+ 
							"[重置]</a>&nbsp;&nbsp;"+
						"<a href=\"javascript:void(0)\" "+
							"id=\"addData\" onclick=\"addRow_M(this)\">"+ 
							"[添加]</a>&nbsp;&nbsp;"+
						"<a href=\"javascript:void(0)\" "+
							"id=\"deleteData\" onclick=\"deleteRow_M(this)\">"+ 
							"[删除]</a>&nbsp;&nbsp;"+
						"<a href=\"javascript:void(0)\" "+
							"id=\"sureData\" >"+ 
							"[确定]</a>&nbsp;&nbsp;"+
						"<a href=\"javascript:void(0)\" "+
							"id=\"closeDL\">"+ 
							"[关闭]</a>&nbsp;&nbsp;"+
					"</div>"+
					"<div id=\"selTab\" class=\"easyui-tabs\" >" +
						"<div title=\"所有\"><div id=\"datalistAll\" ></div></div> " +
						"<div title=\"已选\"><div id=\"datalistFilter\" ></div></div> " +
					"</div> " +
					"<div id=\"selTabM\" >" +    //不需要tabtitle的div,那么就不需要初始化tab
						"<div id=\"datalist_m\"></div>" +
					"</div> " +
				"</div> " +
				"<div id=\"fade\" class=\"black_overlay\"> "+
				"</div> ";

//初始化DataGrid的类型（带勾选框，单选，不可编辑,不带分页）
function initDataGrid_s(own,datacluns,filterObj,allObj){
	$(allObj).datagrid(jointColumnAll_s(own,allObj,datacluns));
	$(allObj).datagrid("keyCtr_dg");       	//绑定datagrid 的键盘事件
	$(filterObj).datagrid(jointColumnFilter_s(own,filterObj,datacluns));
}

//普通弹框加载数据和加载列
function jointColumnAll_s(own,obj,datacluns){
	var lastIndex;
	var options = {  
			idField:datacluns.returnColn,
			iconCls:'icon-save',
			width:$(own).attr("dgw"),
			height:$(own).attr("dgh")-30,
			striped: true,				 
			collapsible:true,
			checkOnSelect:true,
			autoRowHeight: false,
			sortOrder: 'desc',
			singleSelect:true,
			remoteSort: false,
//			frozenColumns:[[
//			    {field:'ck',checkbox:true}
//			]],
			columns:[[]],
			rownumbers:true,
			onSelect:function(rowIndex,rowData){
				addOrDelFilterData_s(own,obj,datacluns,rowData,rowIndex,"0");
			},
			onUnselect:function(rowIndex,rowData){
				addOrDelFilterData_s(own,obj,datacluns,rowData,rowIndex,"1");
			}
		};
	var option=returnColumn_s(datacluns.columns);
	options.columns =option.columns;
	return options;
}

//普通弹框加载数据和加载列
function jointColumnFilter_s(own,obj,datacluns){
	var lastIndex;
	var options = {  
			idField:datacluns.returnColn,
			iconCls:'icon-save',
			height:335,
			width:620,
			striped: true,				 
			collapsible:true,
			checkOnSelect:true,
			autoRowHeight: false,
			sortOrder: 'desc',
			singleSelect:false,
			remoteSort: false,
			frozenColumns:[[
			    {field:'ck',checkbox:true}
			]],
			columns:[[]],
			rownumbers:true,
			onUnselect:function(rowIndex, rowData){
				addOrDelFilterData_s(own,obj,datacluns,rowData,rowIndex,"3");
			}
		};
	var option=returnColumn_s(datacluns.columns);
	options.columns =option.columns;
	return options;
}

//普通弹框列对象
function returnColumn_s(columns){
	var options={};
	var newColumns = new Array();
	for(var i = 0; i < columns.length; i++){
		var column = {};
		column.title = columns[i].colnName
		column.field = columns[i].javaProperyRecourded;
		column.width = column.width = (columns[i].width==null || columns[i].width==0 || columns[i].width=='')?100:columns[i].width ;
		column.sortable = true;
		if(columns[i].hidden == 'T')column.hidden = true;
		if(columns[i].editor != '')column.editor = columns[i].editor;
		if(columns[i].styler != '')column.styler = eval('window.parent.'+columns[i].styler); 
		if(columns[i].formatCont != '')column.formatter = eval('window.parent.'+columns[i].formatCont); 
		newColumns[i] = column;
	}
	var cc = new Array();
	cc[0] = newColumns;
	options.columns = (cc);
	return options;
}




/***********************************************
 * 多选
 **************************************************/
//初始化DataGrid的类型(不带分页,带勾选框，允许多选，不可编辑）
function dzMDGrid_m1(obj,data){
	var lastIndex;
	$(obj).datagrid({
		iconCls:'icon-save',
		width:$(obj).attr("dgw"),
		height:$(obj).attr("dgh")-30,
		striped: true,				 
		collapsible:true,
		checkOnSelect:true,
		autoRowHeight: false,		
		sortOrder: 'desc',
		remoteSort: false,
		singleSelect:false,
		frozenColumns:[[
		    {field:'ck',checkbox:true}
		]],
		columns:[[]],
		sortName:'NUM',
		rownumbers:true
	});
	var dzGridEl = $(obj);
	dzGridEl.datagrid(jointColumn_z(data.columns));//根据配置选项，生成datagrid
}


//初始化DataGrid(不带分页，不带勾选框，与多选和单选无关,可编辑的（如印刷付印单中的印数分配）)
function dzMDGrid_m2(dataGrid,colData){
	var lastIndex;
	$(dataGrid).datagrid({
		iconCls:'icon-save',
		width:$(dataGrid).attr("dgw"),
		height:$(dataGrid).attr("dgh")-30,
		striped: true,				 
		collapsible:true,
		autoRowHeight: false,		
		sortOrder: 'desc',
		remoteSort: false,
		singleSelect:true,
		columns:[[]],
		rownumbers:true,
		onClickRow:function(rowIndex,rowData){
			$(dataGrid).datagrid('endEdit',lastIndex);
			$(dataGrid).datagrid('beginEdit',rowIndex);
			lastIndex = rowIndex;
		}
	});
	dataGrid.datagrid(jointColumn_z(colData.columns));//根据配置选项，生成datagrid
} 

//初始化DataGrid(带分页，不带勾选框，与单选多选无关,可编辑的（版税率）)
function dzMDGrid_m3(dataGrid,colData){
	var lastIndex;
	$(dataGrid).datagrid({
		iconCls:'icon-save',
		width:$(dataGrid).attr("dgw"),
		height:$(dataGrid).attr("dgh")-30,
		striped: true,				 
		collapsible:true,
		autoRowHeight: false,		
		sortOrder: 'desc',
		remoteSort: false,
		singleSelect:true,
		columns:[[]],
		rownumbers:true,
		onClickRow:function(rowIndex,rowData){
			$(dataGrid).datagrid('endEdit', lastIndex);
			$(dataGrid).datagrid('beginEdit', rowIndex);
			lastIndex = rowIndex;
		}
	});
	dataGrid.datagrid(jointColumn_z(colData.columns));//根据配置选项，生成datagrid
} 



//一对多弹框 并且是用实体类查询出的对象
function jointColumn_z(columns){
	var options = {  
			rownumbers: true  
		};
	var newColumns = new Array();
	for(var i = 0; i < columns.length; i++){
		var column = {};
		column.title = columns[i].colnName;
		column.field = columns[i].javaProperyRecourded;
		column.width = (columns[i].width==null || columns[i].width==0 || columns[i].width=='')?100:columns[i].width;
		column.sortable = true;
		if(columns[i].hidden == 'T')column.hidden = true;
		if(columns[i].editor != null && columns[i].editor != ''){
			column.editor = eval('(' +columns[i].editor+')');  
		}		
		if(columns[i].styler != '')column.styler = eval('window.parent.'+columns[i].styler); 
		if(columns[i].formatCont != '')column.formatter = eval('window.parent.'+columns[i].formatCont); 
		if(columns[i].isPkAdd == 'T')column.vpk = 'T';
		newColumns[i] = column;
	}
	var cc = new Array();
	cc[0] = newColumns;
	options.columns = (cc);
	return options;
}


//一对多弹框列对象（用sql语句查出的对象）
function jointColumn_m(columns){
	var options = {  
			rownumbers: true  
		};
	var newColumns = new Array();
	for(var i = 0; i <columns.length; i++){
		var column = {};
		column.title = columns[i].COLN_NAME;
		column.field = columns[i].JAVA_PROPERTY_RECORDED;
		column.width = (columns[i].WIDTH==null || columns[i].WIDTH==0 || columns[i].WIDTH=='')?100:columns[i].WIDTH;
		column.sortable = true;
		if(columns[i].HIDDEN == 'T')column.hidden = true;
		if(columns[i].EDITOR != null && columns[i].EDITOR != ''){
			column.editor = eval('(' +columns[i].EDITOR+')');  
		}		
		if(columns[i].STYLER != '')column.styler = eval('window.parent.'+columns[i].STYLER); 
		if(columns[i].FORMAT_CONT != '')column.formatter = eval('window.parent.'+columns[i].FORMAT_CONT); 
		if(columns[i].IS_PK_ADD == 'T')column.vpk = 'T';
		newColumns[i] = column;
	}
	var cc = new Array();
	cc[0] = newColumns;
	options.columns = (cc);
	return options;
}

//普通弹窗查询条件拼接
function createConfig_s(obj,columns){ //存放条件div
	qhtml = "";
	for(var i = 0; i < columns.length; i++){
		if(columns[i].queryCln == 'T'){   //循环遍历queryCln中设为查询条件的列（后期再把弹框设为可下拉）
			//判断条件文本类型configS
			var inputtype=columns[i].inputType;//查询条件的样式 由  inputtype 改成  inputtype_qr 
			switch (inputtype) {
				case "select":  //自动填充数据
					qhtml += columns[i].colnName+"：<select  onchange='chan_qrdg(this)' onkeydown='if(event.keyCode==13) enterDGQ(this);' style='width:110px' onfocus=\"loadDzG(\'"+columns[i].dsid+"\',\'"+columns[i].name+"\',this)\"  id='"+columns[i].name+"'></select>&nbsp;&nbsp;";
				break;
				default:
					qhtml += columns[i].colnName+"：<input onchange='chan_qrdg(this)' onkeydown='if(event.keyCode==13) enterDGQ(this);' class='qtc_input' id='"+columns[i].name+"'>&nbsp;&nbsp;";
			}
			$(obj).html("<span class='qtc_name'>"+qhtml+"</span>");
		}
	}
}


function chan_qrdg(obj){
	$(obj).attr("ischan","T")
}

/***
 * 普通、一对多加载下拉查询条件中的数据
 * @param dsid
 * @param name
 * @param obj
 * @return
 */
function loadDzG(dsid,name,obj){
	if($(obj).html() == ""){
		$.ajax({
			url:_a_url+'dz/loadDzG',   //加载字段
			data:{'dzId':dsid,'clnName':name},
			type:'post',
			async:false,
			success:function(data){
				$(obj).append("<option></option>");
				for(var i = 0; i < data.length; i ++){
					if(data[i].NAME != null && data[i].NAME != 'NULL' && data[i].NAME != 'null'){
						$(obj).append("<option>"+data[i].NAME+"</option>");
					}
				}
			}
		});
	}
}

/**
 * 普通,一对多常用查询条件回车事件
 * @param obj
 * @return
 */
function enterDGQ(obj){
	var newVal=$(obj).val();
	$(obj).attr("oldVal",newVal);
	$(obj).blur();
	$(obj).focus();
	var queBut = $(obj).parent().parent().parent().find('#query');
	$(queBut).click();
}



function serializeEDIType(formid){
	var naparams = "";
	var naparams = $("#"+formid+" select").map(function(){ 
	if($(this).attr('editype') != null && $(this).attr('editype') != 'null' && $(this).attr('editype') != '') return $(this).attr('editype');
	else return;
	}).get().join(";");
	return naparams;
}


//一对多弹窗查询条件拼接
function createConfig_m(obj,columns){
	qhtml = "";
	for(var i = 0; i < columns.length; i++){
		if(columns[i].commonUse == 'T'){   //循环遍历queryCln中设为查询条件的列（后期再把弹框设为可下拉）
			var inputtype=columns[i].inputtype;//查询条件的样式 由  inputtype 改成  inputtype_qr 
			switch (inputtype) {
			case "select":  //自动填充数据
				qhtml += columns[i].colnName+"：<select  onkeydown='if(event.keyCode==13) enterDGQ(this);' style='width:110px' onfocus=\"loadDzG(\'"+columns[i].dsid+"\',\'"+columns[i].name+"\',this)\"  id='"+columns[i].name+"'></select>&nbsp;&nbsp;";
			break;
			default:
				qhtml += columns[i].colnName+"：<input onkeydown='if(event.keyCode==13) enterDGQ(this);' class='qtc_input' id='"+columns[i].name+"'>&nbsp;&nbsp;";
			}
		}
	}
	$(obj).html("<span class='qtc_name'>"+qhtml+"</span>");
}




//一对多弹框点击查询事件触发的方法
function query_m(obj){
	var allConfig=$(obj).parent().children('#light').find('#configS').find('span input');   //存放输入查询条件的文本框
	var dataGObjM = $(obj).parent().find('div #datalist_m');
	var dataGobjAll=$(obj).parent().find('div #datalistAll');      //所有
	var dataGobjFilter=$(obj).parent().find('div #datalistFilter'); //已选
	var dsId=$(obj).attr("dsid");
	var coluname=$(obj).attr("qucln");
	var sinKey=$(obj).val();    //获得一对多表的关联键的值
	var config="";
	var filterConfig = "";
	if(dsId === 'ds_zc_authorverification_cl') {
        var PAY_PARTY = $('#zzhxd_addWinTable input[qucln=PAY_PARTY]').val();
        filterConfig += " AND PAY_PARTY = '" + PAY_PARTY + "' ";
	}
	for(var i=0;i<allConfig.length;i++){
		var configVal=$(allConfig[i]).val();
		if(typeof(configVal)!="undefined"&&configVal!=""){
			var configName=$(allConfig[i]).attr("id");
			if(typeof(configName)=="undefined"||configName==""){
				$.messager.alert("查询提示：","请检查查询条件的格式封装是否正确");
			}
			var str=configName+"-"+configVal+";";
			config+=str;
		}
	}
	var allConfigS=$(obj).parent().children('#light').find('#configS').find('span select');   //存放输入查询条件的下拉
	for(var i=0;i<allConfigS.length;i++){
		var configVal=$(allConfigS[i]).find("option:selected").text();
		if(typeof(configVal)!="undefined"&&configVal!=""){
			var configName=$(allConfigS[i]).attr("id");
			if(typeof(configName)=="undefined"||configName==""){
				$.messager.alert("查询提示：","请检查查询条件的格式封装是否正确");
			}
			var str=configName+"-"+configVal+";";
			config+=str;
		}
	}
	if($(obj).attr('modeltype')==7||(obj).attr('modeltype')==5){
		$.ajax({
			type:'post',
			url:_a_url+'dz/loadMulEditData',
			data:{"dsid":dsId,"key":sinKey,"coluname":coluname,"config":config, "filterConfig":filterConfig},
			async:false,
			success:function(data){
				$(dataGObjM).datagrid('loadData',data);
			}
		});
	}else if($(obj).attr('modeltype')==6){
		$.ajax({
			type:'post',
			url:_a_url+'dz/loadMulEditData',
			data:{"dsid":dsId,"key":sinKey,"coluname":coluname,"config":config, "filterConfig":filterConfig},
			async:false,
			success:function(data){
				$(dataGobjAll).datagrid('loadData',data);
			}
		});
	}
}



//获取弹框过滤条件的拼接
function getFilterStr(obj){
	var sqlStr="";
	//获取弹框的的过滤字段条件条件的拼接
	var datalistfilter=$(obj).attr("datalistfilter");
	var objform=$($(obj).parents("form")[0]);
	var prefix=$(objform).attr("pre");
	var formId="";
	var clunsStr=datalistfilter.split(";");
	if($(objform).attr("sflag")=="s"){   //单录单
		formId="_A_AFORM";
	}else if($(objform).attr("sflag")=="m"){  //主明细   
		formId="_addWinForm";
	}else if($(objform).attr("sflag")=="d") { //窗口
        formId="_addDialogForm";
	}
	if (datalistfilter.indexOf("1=1")<0) {
		for(var i=0;i<clunsStr.length;i++){
			if(clunsStr[i]!=null&&clunsStr[i]!='undefined'&&clunsStr[i]!=""){
				var clunsName=clunsStr[i].split("-")[0];   //字段名
				var eletype=clunsStr[i].split("-")[1];     //字段在前台显示的类型，或者是一个值
				var clunType=clunsStr[i].split("-")[2];
				var val="";
				if(eletype!='input'&&eletype!='select'){
					val=eletype;
				}else{
                    if(!formId) {
                        return;
                    }
					val=$("#"+prefix+formId+" "+eletype+"[qucln="+clunsName+"]").val();
					if(val==undefined||val=='undefined'){
						$.messager.alert("温馨提示","请检查"+$(obj).attr("qucln")+"的字段datalist_filter的配置的类型是否正确");
						return sqlStr;
					}
				}
				$("#"+prefix+formId+" "+eletype+"[qucln="+clunsName+"]").bind("change",function(){  
					clearDataListVal(obj);
				});
				if(val==""){
					var filterName=$("#"+prefix+formId+" "+eletype+"[qucln="+clunsName+"]").parent().prev().text();
					$.messager.alert("温馨提示",'亲，请先录入  '+filterName.substring(0,filterName.trim().length-1).replace('*',''));//去除必录字段中的*
					return "false";
				}
				var clunsVal=clunsName+"='"+val+"'";
				sqlStr+=clunsVal+" and "
			}
		}
		if(sqlStr!=""){
			//移除最后一个and
			sqlStr=sqlStr.substring(0,sqlStr.lastIndexOf("and"));
		}
	}else{
		//把1=1移除了
		for(var i=0;i<clunsStr.length;i++){
			if(clunsStr[i]!='1=1'){
				var clunsName=clunsStr[i].split("-")[0];   //字段名
				var eletype=clunsStr[i].split("-")[1];     //字段在前台显示的类型，或者是一个值
				if(eletype!='input'&&eletype!='select'){
					val=eletype;
				}else{
					if(!formId) {
						return;
					}
					val=$("#"+prefix+formId+" "+eletype+"[qucln="+clunsName+"]").val();
					if(val==undefined||val=='undefined'){
						$.messager.alert("温馨提示","请检查"+$(obj).attr("qucln")+"的字段datalist_filter的配置的类型是否正确");
						return sqlStr;
					}
				}
				
				$("#"+prefix+formId+" "+eletype+"[qucln="+clunsName+"]").bind("change",function(){  
					clearDataListVal(obj);
				});
				
				if(val==""){
					var filterName=$("#"+prefix+formId+" "+eletype+"[qucln="+clunsName+"]").parent().prev().text();
					$.messager.alert("温馨提示",'亲，请先录入  '+filterName.substring(0,filterName.trim().length-1).replace('*',''));//去除必录字段中的*
					return "false";
				}
			}
		}
	}
	var editype = $(obj).attr("editype");
	if(editype == 'dz_fx_dzjs_sk'){		 //收款单
		clunsName = 'JS_ID';
		var jsId = $("#"+prefix+formId+" "+eletype+"[qucln="+clunsName+"]").val();
		sqlStr += "and JS_ID NOT IN (SELECT C.JS_ID FROM FX_CHARGE C WHERE NVL(C.IS_DESTROY,'0')='0') AND " +
				"JS_ID != '"+jsId+"'";
	}else if(editype == 'dz_fx_dzjs'){ //开票单
		clunsName = 'JS_ID';
		var jsId = $("#"+prefix+formId+" "+eletype+"[qucln="+clunsName+"]").val();
		sqlStr += "and JS_ID NOT IN (SELECT K.JS_ID FROM FX_INVOICE_KP K WHERE NVL(K.IS_DESTROY,'0')='0') AND " +
				"JS_ID != '"+jsId+"'";
	}else if(editype == 'dz_fx_kp'){ //票款核销
		clunsName = 'INV_ID';
		var invId = $("#"+prefix+formId+" "+eletype+"[qucln="+clunsName+"]").val();
		sqlStr += "and INV_ID NOT IN (SELECT I.INV_ID FROM FX_XS_INVCH I WHERE NVL(I.IS_DESTROY,'0')='0') AND " +
				"INV_ID != '"+invId+"'";
//	}
//	else if(editype == 'dz_product_xs'){	//新书分发
//		clunsName = 'O_ID_LASTGR';
//		var oid = $("#"+prefix+formId+" "+eletype+"[qucln="+clunsName+"]").val();
//		sqlStr += " not exists(select 1 from fx_ff_clients ff where nvl(ff.is_destroy,'0')='0' AND ff.h_id=QUERYTMP.h_id AND " + 
//		" ff.O_ID_LASTGR='"+oid+"'" + ")";
}
	return sqlStr;
}





//把弹框移除
function clearDataListVal(obj){
	$(obj).val("");
	$(obj).next().val("");
	$(obj).attr("chan","T");
	$(obj).parent().children('#light').remove();  
	$(obj).parent().children('#fade').remove();   
}


//编辑成本费用单冲减成本费用单弹框的前置回调函数
function crushCostPay(){
	//得到单据类型和业务对象
	var djId=$("#abo_A_AFORM select[qucln='DJ_TYPE']").val();   
	var businessObj=$("#abo_A_AFORM input[qucln='MAN_BUSINESS']").val();  
	if(djId=='costDjType.002'){    //单据类型为冲预成本的时候
		$.messager.alert("操作提示","亲，当单据类型为《预付成本》的时候，不能选择冲减成本费用");
	}else{
		if(djId==''){
			$.messager.alert("操作提示","亲,当单据类型为空，不能选择冲减成本费用！"); 
			return;
		}
		//获取冲减成本费用的对象
		if(businessObj==''){
			$.messager.alert("操作提示","冲减成本费用的时候请先选择《业务对象》");
			return;
		}
		var obj=$("#abo_A_AFORM input[qucln='CRUSH_COST_ID']");
		$("#abo_A_AFORM select[qucln='DJ_TYPE']").bind("change",function(){  
			clearDataListVal(obj);
		});
		$("#abo_A_AFORM input[qucln='MAN_BUSINESS']").bind("change",function(){  
			clearDataListVal(obj);
		});
		showDataList_s1(obj);
	}
}

//新书分发，前置判断
function isffsadnoidnull(){
	//获取首印数和业务员的数据
	var conutisnull = $("#ffc_addWinTable").find("input[qucln='YFF_AMOUNT']").val();  //首印数
	var oidisnull = $("#ffc_addWinTable").find("input[qucln='O_ID_LASTGR']").val();  //业务员
    if (conutisnull == '' && oidisnull == '') {
        $.messager.alert('温馨提示', '亲，业务员和首印数没有填写哦！请输入！');
        return;
    }else if (conutisnull == '') {
        $.messager.alert('温馨提示', '亲，首印数没有填写哦！请输入！');
        return;
    }else if (oidisnull == '') {
        $.messager.alert('温馨提示', '亲，片区经理没有填写哦！请输入！');
        return;
    }else{
    	var obj = $("#ffc_addWinTable").find("input[qucln='H_ID']");
    	showDataList_s1(obj);
    }
    
}
//编辑成本单关联选题的选题名称判断
//编辑-预估成本老的调用方法
function xtLinkPay(){
	//得到是否关联选题的选择
	var djId=$("#abo_A_AFORM select[qucln='IS_LINK_XT']").val();   
	if(djId=='0'){    //单据类型为冲预成本的时候
		$.messager.alert("操作提示","亲，本单据选择的是【不关联选题】，不能选择选题名称哦！");
	}else{
		var obj=$("#abo_A_AFORM input[qucln='XT_ID']");
		$("#abo_A_AFORM select[qucln='IS_LINK_XT']").bind("change",function(){  
			clearDataListVal(obj);
		});
		showDataList_s1(obj);
	}
}


//编辑作者版税冲减成本费用单弹框的前置回调函数
function crushYFCostPay(){
	//得到单据类型和业务对象
	var djId=$("#aae_A_AFORM select[qucln='DJ_TYPE']").val();   
	var businessObj=$("#aae_A_AFORM input[qucln='MAN_BUSINESS']").val();  
	if(djId==''){
		$.messager.alert("操作提示","亲,当单据类型为空，不能选择冲减成本费用！"); 
		return;
	}
	//获取冲减成本费用的对象
	if(businessObj==''){
		$.messager.alert("操作提示","冲减成本费用的时候请先选择《业务对象》");
		return;
	}
	var obj=$("#aae_A_AFORM input[qucln='CRUSH_COST_ID']");
	$("#aae_A_AFORM select[qucln='DJ_TYPE']").bind("change",function(){  
		clearDataListVal(obj);
	});
	$("#aae_A_AFORM input[qucln='MAN_BUSINESS']").bind("change",function(){  
		clearDataListVal(obj);
	});
	showDataList_s1(obj);
}



//编辑作者版税单关联选题的选题名称判断
function xtBsLinkPay(){
	//得到是否关联选题的选择
	var djId=$("#aae_A_AFORM select[qucln='IS_LINK_XT']").val();   
	if(djId=='0'){    //单据类型为冲预成本的时候
		$.messager.alert("操作提示","当前为不关联选题状态，不能选择选题哦！");
	}else{
		var obj=$("#aae_A_AFORM input[qucln='XT_ID']");
		$("#aae_A_AFORM select[qucln='IS_LINK_XT']").bind("change",function(){  
			clearDataListVal(obj);
		});
		showDataList_s1(obj);
	}
}



//报销费用单冲减成本费用单弹框的前置回调函数
function bxcrushCostPay(){
	//得到单据类型和业务对象
	var djId=$("#dag_A_AFORM select[qucln='DJ_TYPE']").val();   
	var businessObj=$("#dag_A_AFORM input[qucln='MAN_BUSINESS']").val();  
	if(djId == 'costDjType.004'){    //单据类型为报销费用冲预付的时候
		$.messager.alert("操作提示","亲,当单据类型为《借款单》的时候，不能选择冲减借款费用！"); 
		return;
	}else{
		if(djId==''){
			$.messager.alert("操作提示","亲,当单据类型为空，不能选择冲减借款费用！"); 
			return;
		}
		if(businessObj==''){
			$.messager.alert("操作提示","亲，冲减借款单费用的时候请先选择《申请人》！");
			return;
		}
		//获取冲减成本费用的对象
		var obj=$("#dag_A_AFORM input[qucln='CRUSH_COST_ID']");
		$("#dag_A_AFORM select[qucln='DJ_TYPE']").bind("change",function(){  
			clearDataListVal(obj);
		});
		$("#dag_A_AFORM input[qucln='MAN_BUSINESS']").bind("change",function(){  
			clearDataListVal(obj);
		});
		showDataList_s1(obj);
	}
}

//报销单关联选题的选题名称判断
function xtBxLinkPay(){
	//得到是否关联选题的选择
	var djId=$("#dag_A_AFORM select[qucln='IS_LINK_XT']").val();   
	if(djId=='0'){    //单据类型为冲预成本的时候
		$.messager.alert("操作提示","当前为不关联选题状态，不能选择选题哦！");
	}else{
		var obj=$("#dag_A_AFORM input[qucln='XT_ID']");
		$("#dag_A_AFORM select[qucln='IS_LINK_XT']").bind("change",function(){  
			clearDataListVal(obj);
		});
		showDataList_s1(obj);
	}
}


//译作合同 账号弹框的前置回调函数
function translationContract(){
	//获取译者
	var translator=$("#fba_A_AFORM input[qucln='INTERPRETER_MAN']").val();   
	if(translator==null||translator==""){    //单据类型为普通成本冲预付的时候
		$.messager.alert("操作提示","请先选择译者","info");
		$(translator).focus();
		return;
	}
	var obj=$("#fba_A_AFORM input[qucln='BANK_CARD_NO']");
	showDataList_s1(obj);
}


//著作合同 账号弹框的前置回调函数
function zuContract(){
	//获取许可方
	var zuContract=$("#abf_A_AFORM input[qucln='JIAFANG']").val();   
	if(zuContract==null||zuContract==""){    //单据类型为普通成本冲预付的时候
		$.messager.alert("操作提示","请先选择许可方","info");
		$(zuContract).focus();
		return;
	}
	var obj=$("#abf_A_AFORM input[qucln='BANK_CARD_NO']");
	showDataList_s1(obj);
}

//开票申请，结算单号根据客户信息拉取的回调
function kpJsfunc(){
	//获取客户Id
	var clientID=$("#cbg_addWinForm input[qucln='CLIENT_ID']").val();   
	if(clientID==null||clientID==""){  
		$.messager.alert("操作提示","请先选择客户","info");
		$(clientID).focus();
		return;
	}
	var obj=$("#cbg_addWinForm input[qucln='JS_ID']");
	showDataList_s1(obj);
}
//客户收款，结算单号根据客户信息拉取的回调
function khSkfunc(){
	//获取客户Id
	var clientID=$("#cbk_addWinForm input[qucln='CLIENT_ID']").val();   
	if(clientID==null||clientID==""){  
		$.messager.alert("操作提示","请先选择客户","info");
		$(clientID).focus();
		return;
	}
	var obj=$("#cbk_addWinForm input[qucln='INV_ID']");
	showDataList_s1(obj);
}

//票款核销，发票单号根据客户信息拉取的回调
function pkHxfunc(){
	//获取客户Id
	var clientID=$("#fic_addWinForm input[qucln='CLIENT_ID']").val();   
	if(clientID==null||clientID==""){  
		$.messager.alert("操作提示","请先选择客户","info");
		$(clientID).focus();
		return;
	}
	var obj=$("#fic_addWinForm input[qucln='INV_ID']");
	showDataList_s1(obj);
}

//印制成本费用单冲减成本费用单弹框的前置回调函数
function yzCrushCostPay(){
	//得到单据类型和业务对象
	var djId=$("#baq_A_AFORM select[qucln='DJ_TYPE']").val();   
	var businessObj=$("#baq_A_AFORM input[qucln='MAN_BUSINESS']").val();  
	if(djId=='costDjType.002'){    //单据类型为冲预成本的时候
		$.messager.alert("操作提示","亲，当单据类型为《预付成本》的时候，不能选择冲减成本费用");
	}else{
		if(djId==''){
			$.messager.alert("操作提示","亲,当单据类型为空，不能选择冲减成本费用！"); 
			return;
		}
		//获取冲减成本费用的对象
		if(businessObj==''){
			$.messager.alert("操作提示"
					
					,"冲减成本费用的时候请先选择《业务对象》");
			return;
		}
		var obj=$("#baq_A_AFORM input[qucln='CRUSH_COST_ID']");
		$("#baq_A_AFORM select[qucln='DJ_TYPE']").bind("change",function(){  
			clearDataListVal(obj);
		});
		$("#baq_A_AFORM input[qucln='MAN_BUSINESS']").bind("change",function(){  
			clearDataListVal(obj);
		});
		showDataList_s1(obj);
	}
}





//通用打开遮罩(适用所有的弹框)
function fadeWin(obj){
	$(obj).children('#light').css('display','block');   //把弹框显示

	$(obj).children('#fade').css('display','block');    //把这个单据遮住
//	moveDiv($(obj).children('#light'));					//设置弹框的可移动性
}

//通用确认按钮弹框关闭事件
function sureClose(obj){
	$(obj).parent().children('#light').css('display','none');  //把弹框隐藏
	$(obj).parent().children('#fade').css('display','none');   //把遮罩隐藏
	$(obj).next("input[dgs=true]").focus();
	//判断有没有查询条件，如果有查询条件，那么就重置
}



//通用关闭按钮弹框窗口事件
function closeDataList(obj){
	//清除datagrid的数据
	var modelType=$(obj).attr("modeltype");   //获得一对多模板的类型
	if(modelType==7||modelType==5){   //无勾选
		var dataGObjM = $(obj).parent().find('div #datalist_m');    //整个div弹框对象
		var allLength = $(dataGObjM).datagrid('getRows').length;
		for(var i=0;i<allLength;i++){
			$(dataGObjM).datagrid('endEdit',i);
		}
	}
	//获取datagrid 的所有行，并关闭
	$(obj).parent().children('#light').css('display','none');  //把弹框隐藏
	$(obj).parent().children('#fade').css('display','none');   //把遮罩隐藏
	$(obj).next("input[dgs=true]").focus();
}



//通用弹窗光标定位
function focusE(obj,flag){
	var inputs = $(obj).parent().find('#configS').find("input");
	if($(inputs).length>0){
		$($(inputs)[0]).focus();
 	}
}


//新书分发，前置判断
function iskh_datenotnull(){
    //获取首印数和业务员的数据
    var conutisnull = $("#khhkjh_addWinTable").find("input[qucln='KH_DATE']").val();  //日期
    if (conutisnull == '') {
        $.messager.alert('温馨提示', '亲，日期没有填写哦！请输入！');
        return;
    }else{
        var obj = $("#khhkjh_addWinTable").find("input[qucln='O_ID_LASTGR']");
        showDataList_s1(obj);
    }

}